﻿//tamt 2009.09.13 ver0.2;

var doc = fl.getDocumentDOM();
var folderPath = doc.pathURI.substring(0, doc.pathURI.lastIndexOf('/')+1);
if(doc.selection.length>0){
	doc.clipCopy();
	var ele = doc.selection[0];
	var isLibraryItem = ele.libraryItem?true:false;
	var ox = ele.x;
	var oy = ele.y;
	if(isLibraryItem){
		var itemName = ele.libraryItem.name;
	}
	
	doc = fl.createDocument();
	doc.clipPaste();
	ele = doc.selection[0];
	ele.x = 0;
	ele.y = 0;
	
	var as = "x = "+ox+";\ny = "+oy+";";
	doc.getTimeline().layers[0].frames[0].actionScript = as;
	
	if(isLibraryItem){
		itemName = itemName.substring((itemName.indexOf('/')>=0)?(itemName.lastIndexOf('/')+1):0, itemName.length);
		fl.saveDocument(doc,folderPath + itemName + '.fla');
		doc.testMovie();
		fl.closeAllPlayerDocuments();
		//fl.closeDocument(doc);
	}else{
		doc.save();
	}
}else{
	alert('请先选中一张图片.');
}